import { setCookie } from '..//tools.js';
import { APILogina } from '..//fetch.js';


layui.use(['layer'], function () {
    var layer = layui.layer;

    $('.layui-btn').click(function () {
        var username = $('#username').val();
        var password = $('#password').val();
        console.log(username, password);

        APILogina({
            username,
            password
        }).then(( {code, msg} ) => {
            // console.log(data);
            if (code) {
                layer.msg(msg);
                setCookie('login_user', username);

                var loginBack = sessionStorage.loginBack || '../dewu/liebiao.html';
                location.href = loginBack;
            } else {
                layer.msg(msg);
            }
        })

    })
})
